<!Doctype html>
<html>
<head></head>
<body>
<script>
    var doc = document;
    var fragment = document.createDocumentFragment();
    var test = doc.createElement('div');
    test.innerHTML = '<p id="test">111</p>';
    fragment.appendChild(test);
    var btn = fragment.getElementById('test');
    btn.onclick = function () {
        this.innerHTML = '222';
    }

    document.body.appendChild(fragment);
    function parseHTML(_data) {
        var tmp = document.createElement("div");
        tmp.innerHTML = _data;
        return tmp.childNodes;
    }
    console.log(parseHTML('<div><p>111</p></div><div></div>').length);
</script>
</body>
</html>